<extend name="Extends/base" />
<block name="title">收徒裂变任务</block>
<block name="css">
</block>
<block name="body_style">class="bgc-f2f4f6"</block>
<block name="body">
    <div class="pt30 plr20">
        <div class="form-layout form-inline">
            <form id='myForm'>
                <em class="pop-close"></em>
                <div class="control-group">
                    <label class="control-label c-t-right"> 任务完成月份：</label>
                    <div class="control-form">
                        <div class="date-wrap  w200">
                            <input type="text" autocomplete="off" class="date-txt datetimepicker date-year-month"
                                name="finish_time" value="{:date('Y-m')}">
                        </div>
                    </div>
                </div>

            </form>

            <div class="control-group">
                <a href="javascript:;" class="c-btn c-btn-blue mr10 search-btn">查询</a>
            </div>
        </div>

        <div class="c-nodata pt100 c-t-center">
            <img src="__PC__/images/nodata.png">
            <p class="pt30 c-f14 msg"></p>
        </div>

        <div id="myList" class="c-hide">
        </div>
    </div>
</block>
<block name="js">
    <script type="text/javascript" src="__WOR__/js/api.js?v={:C('JS_CSS_VERSION')}"></script>
    <script type="text/javascript" src="__WOR__/js/recomm.api.js?v={:C('JS_CSS_VERSION')}"></script>
    <!-- 日期控件 -->
    <script type="text/javascript" src="__PC__/widget/My97DatePicker/WdatePicker.js?v={:C('JS_CSS_VERSION')}"></script>

    <script type="text/javascript">
        var currPage = 1;
        $(function () {

        });

        //初始化时间控件
        $(document).on("click", ".date-year-month", function () {
            WdatePicker({
                dateFmt: 'yyyy-MM'
            });
        });

        //点击搜索
        $(document).on('click', '.search-btn', function () {
            getTaskList(currPage = 1);
        });

        //点击分页
        $(document).on('click', '.my-page li a', function () {
            var page = $(this).attr('data-page');
            if (!page) {
                return false;
            }

            var total = $('.my-page').attr('data-total');
            if (parseInt(page) > parseInt(total)) {
                page = total;
            }
            getTaskList(currPage = page);
        });



        /**
         * 获取裂变列表
         **/
        function getTaskList(page, callback) {
            if (typeof callback != "function") {
                callback = emptyFunc;
            }
            var data = getFormData();
            page = page ? page : 1;
            data.page = page;

            if (!data.finish_time) {
                $.toast("请输入查询月份");
                return false;
            }

            doGetTaskList(data, function (res) {
                if (res.Code != 10000) {
                    showErr(res.Message);
                    $('#myList').hide();
                    callback(res);
                    return false;
                }

                $('#myList').show().html(res.Result);
                hideErr();
                callback(res);
            })
        }

        /**
         * 显示页面错误页面
         * @param msg
         */
        function showErr(msg) {
            $('.c-nodata').show().find('.msg').html(msg);
        }

        /**
         * 隐藏错误页面
         */
        function hideErr() {
            $('.c-nodata').hide().find('.msg').text('');
        }
    </script>
</block>